<?php
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
if(@!in_array('video',$navarr))exit('该功能已关闭');
$chk_u_jumpurl=mHref('video');require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'m/div_left_so.php';
if($submitok== 'ajax_agree'){
	if (!ifint($fid))json_exit(array('flag'=>0,'msg'=>'视频不存在'));
	$db->query("UPDATE ".__TBL_VIDEO__." SET agree=agree+1 WHERE id=".$fid);
	json_exit(array('flag'=>1,'msg'=>'点赞成功'));
}
//门店
if(!empty($AGT)){
	$agentSQL2=" AND b.agentid=".$AGT['agentid'];
}
//门店结束
$nodatatips = "<div class='nodatatips'><i class='ico'>&#xe608;</i>暂时木有视频</div>";
$_ZEAI['pagesize']= 8;$ZEAI_SQL = " a.flag=1 AND a.uid=b.id AND b.flag=1 ".$agentSQL2;
//处理表单
$keyword = trimhtml(dataIO($keyword,'out'));
if (!empty($keyword)){
	if (ifint($keyword)){
		$ZEAI_SQL .= " AND b.id='$keyword' ";
	}else{
		$ZEAI_SQL .= " AND b.nickname LIKE '%".$keyword."%' ";
	}
}
$sex=trimhtml(dataIO($sex,'out'));if(!empty($sex))$ZEAI_SQL .= doinsql('b.sex',$sex);
$addtime=intval($addtime);if(ifint($addtime)){$addtimeF=$addtime*86400;$ZEAI_SQL .= " AND (a.addtime - ".ADDTIME.") < $addtimeF AND a.addtime>".ADDTIME;}
$areaid=trimhtml(dataIO($areaid,'out'));$areaid=getareaSQL($areaid);if(!empty($areaid))$ZEAI_SQL .= " AND b.areaid LIKE '%".$areaid."%' ";
$age=trimhtml(dataIO($age,'out'));
if(!empty($age)){
	$agearr=explode(',',$age);
	if (count($agearr) >= 1 && is_array($agearr)){
		$SQL="";
		foreach ($agearr as $V) {
			$V=explode('-',$V);$V1=intval($V[0]);$V2=intval($V[1]);$SQL1="";$SQL2="";
			if(ifint($V1))$SQL1 = "  ( (YEAR(CURDATE())-YEAR(b.birthday)-(RIGHT(CURDATE(),5)<RIGHT(b.birthday,5))) >= '$V1' ) ";
			if(ifint($V2))$SQL2 = "  ( (YEAR(CURDATE())-YEAR(b.birthday)-(RIGHT(CURDATE(),5)<RIGHT(b.birthday,5))) <= '$V2' ) ";
			if(!empty($SQL1) && !empty($SQL2)){
				if(!empty($SQL))$SQL .= " OR ";
				$SQL .= "(".$SQL1." AND ".$SQL2.")";
			}
		}
		$ZEAI_SQL .= " AND (".$SQL.") ";
	}
}
$love=trimhtml(dataIO($love,'out'));if(!empty($love))$ZEAI_SQL .= doinsql('b.love',$love);
$edu=trimhtml(dataIO($edu,'out'));if(!empty($edu))$ZEAI_SQL .= doinsql('b.edu',$edu);
//参数
$par = "&sex=".$sex."&addtime=".$addtime."&areaid=".$areaid."&age=".$age."&love=".$love."&edu=".$edu."&areatitle=".$areatitle;
$cs  =" keyword=".$keyword.$par;
//
$ZEAI_SELECT = "SELECT a.id,a.uid,a.path_s,a.addtime,a.agree,a.click,b.sex,b.grade,b.nickname,b.photo_s,b.photo_f,b.birthday,b.pay,b.edu,b.flag,b.photo_ifshow FROM ".__TBL_VIDEO__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
//
$rtt = $db->query("SELECT COUNT(*) FROM ".__TBL_VIDEO__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL);
$roww = $db->fetch_array($rtt);
$ZEAI_total  = $roww[0];
$ZEAI_totalP = ceil($ZEAI_total/$_ZEAI['pagesize']);
if ($submitok == 'ajax_list'){
	exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));
}	
$nav = 'video';
/***********************正文开始***************************/
?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $headertitle;?><?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/video.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/video.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/areadata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/zeai_div_area.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
 if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>res/jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug:false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']
	});
	var share_title = '会员小视频 - <?php echo dataIO($_ZEAI['siteName'],'out'); ?>',
	share_desc  = '我在这个平台发布了个人视频，来看看啊,别忘了给我点赞^_^',
	share_link  = '<?php echo HOST; ?>/?z=video',
	share_imgUrl= '<?php echo UP.$_ZEAI['logo']; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:share_title,desc:share_desc,link:share_link,imgUrl:share_imgUrl});
		wx.onMenuShareTimeline({title:share_title,link:share_link,imgUrl:share_imgUrl});
	});
	</script>
<?php }?>
<style>
#backtop a{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
/*div_left_so*/
.div_left_so a.ed,
.div_left_so a.ed:after{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so ul.def li.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.div_left_so .listbox dl dd span.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul dt.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul li a.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
<?php if($_ZEAI['m_mb']==1){?>
	.ZEAI_list{margin-top:7rem}
	.topnav1{background-image:url("<?php echo RES;?>m/img/my_bg.png");background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
	.topnav a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
	.topnav1 a.ed:after{background-color:#fff}
<?php }?>
</style>
</head><body>
<?php if ($_ZEAI['m_mb']==2){$TRnav_btn = 'hide';require_once ZEAI.'m/top2.php';?>
	<div class="tab2">
        <a href="video.php"><i class="_new ico">&#xe68a;</i><span>最新</span></a>
        <a href="my_video.php"><i class="_my ico">&#xe63e;</i><span>我的</span></a>
		<a href="my_video.php?jumpurl=<?php echo mHref('video');?>"><i class="_add ico">&#xe622;</i><span>上传</span></a>
        <a id="video_search"><i class="_so ico">&#xe68c;</i><span>筛选</span></a>
    </div>
<?php }else{?>
    <div class="topnav<?php echo ($_ZEAI['m_mb']==1)?' topnav1':'';?>">
        <a href="video.php"<?php echo (empty($submitok) || $submitok=='add')?' class="ed"':'';?>>视频</a>
        <a href="my_video.php">我的视频</a>
        <a href="my_video.php?jumpurl=<?php echo mHref('video');?>"><i class="ico">&#xe68a;</i> 我要上传</a>
		<a id="video_search"><i class="ico">&#xe68c;</i> 筛选</font></a>
    </div>
<?php }?>
<div class="ZEAI_list" id="ZEAI_list"><?php if($ZEAI_totalP>0){echo Zeai_ajax_list_fn($ZEAI_totalP,$p);}else{echo $nodatatips;}?></div>
<?php if ($ZEAI_total > $_ZEAI['pagesize']){?>
<script>
var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
var scs='<?php echo trimhtml($cs); ?>';
var postjson = {submitok:'ajax_list',ZEAI_totalP:ZEAI_totalP};
if(!zeai.empty(scs))Object.assign(postjson,tojson(scs.split('&')));
zeaiOnscroll_json={url:MHOST+'/video'+zeai.extname,data:postjson};
document.body.onscroll = zeaiOnscrollv;
</script>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<div class="blankbottom">没有更多视频了</div>
<?php }?>
<!--div_left_so-->
<div class="div_left_so" id="video_so">
	<form action="<?php echo HOST;?>/m/video.php" class="form_uid" name="www.zeai.cn">
        <input name="keyword" type="text" class="input" id="keyword" maxlength="20" value="<?php echo $keyword;?>" placeholder="按发布人UID/昵称" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
	</form>
    <form action="<?php echo HOST;?>/m/video.php" method="get" name="www.yzlove.com">
    <?php
	div_left_so_out(array('tbody'=>'性别','t'=>'sex','tv'=>$sex,'subkind'=>3,'newarr'=>json_decode($_UDATA['sex']),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'年龄','t'=>'age','tv'=>$age,'subkind'=>3,'newarr'=>json_decode('[{"i":"18-22","v":"18-22岁"},{"i":"23-25","v":"23-25岁"},{"i":"26-30","v":"26-30岁"},{"i":"31-35","v":"31-35岁"},{"i":"36-40","v":"36-40岁"},{"i":"41-45","v":"41-45岁"},{"i":"51-60","v":"51-60岁"},{"i":"61-120","v":"60岁以上"}]'),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'婚况','t'=>'love','tv'=>$love,'subkind'=>3,'newarr'=>json_decode($_UDATA['love']),'ulcls'=>' col3','show'=>'off'));
	div_left_so_out(array('tbody'=>'学历','t'=>'edu','tv'=>$edu,'subkind'=>3,'newarr'=>json_decode($_UDATA['edu']),'ulcls'=>' col3','show'=>'off'));
	div_left_so_out(array('tbody'=>'上传时间','t'=>'addtime','tv'=>$addtime,'subkind'=>2,'newarr'=>json_decode('[{"i":"3","v":"3天内"},{"i":"7","v":"1周内"},{"i":"30","v":"1月内"}]'),'ulcls'=>' col3','show'=>'off'));
	?>
    <!--地区-->
    <div id="areabox" class="areabox div_left_so_areabox"><div class="ul"><li><dl><dd></dd></dl></li></div></div>
    <input type="hidden" id="form_areaid" name="areaid" value="<?php echo $areaid;?>">
    <input type="hidden" id="form_areatitle" name="areatitle" value="<?php echo $areatitle;?>">
    <div class="listbox"><dl id="areaid" data="<?php echo $areaid;?>"><dt>所在地区</dt><dd><span id="areatitle"><?php echo $areatitle;?></span></dd></dl></div>
	<script>
	o('areaid').onclick=function(){
		ZeaiM.div_up({obj:areabox,h:36});
		ZEAI_area({areaid:o('form_areaid').value,areatitle:o('form_areatitle').value,ul:areabox.children[0],bx:true,str:'job',end:function(z,e){
			o('areatitle').html(e);o('areatitle').class('ed');
			o('form_areaid').value=z;
			o('form_areatitle').value=e;
		}});
	}
	div_left_so_init('video_so');
    </script>
    <div class="savebox"><button type="button" class="btn size3 reset" id="div_left_so_resetbtn" onClick="div_left_so_reset('video_so')">重置</button><button type="submit" class="btn size3 zeaibg ico">&#xe6c4; 确定</button></div>
    </form>
</div>
<!--div_left_so end-->
<script>
var browser='<?php echo browser();?>';init();
video_search.onclick=video_so_btnFn;
</script>
<?php
require_once ZEAI.'m/TRnav.php';
if($_ZEAI['m_mb']==2){
	echo "<script>setTimeout(function(){hdnavLRmoveFn(hdnav,30,'r');},100);</script>";
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/bottom.php';
}
if (!empty($_GZH['wx_gzh_ewm']) && ifint($cook_uid)){wx_endurl('您刚刚浏览的页面【视频】',mHref('video'));}
function rows_ulist($rows) {
	global $_ZEAI,$db;
	$id            = $rows['id'];
	$uid           = $rows['uid'];
	$path_s        = $rows['path_s'];
	$addtime_str   = date_str($rows['addtime']);
	$sex           = $rows['sex'];
	$grade         = $rows['grade'];
	$nickname      = trimhtml(dataIO($rows['nickname'],'out'));
	$photo_s       = $rows['photo_s'];
	$photo_f       = $rows['photo_f'];
	$birthday      = $rows['birthday'];
	$pay           = $rows['pay'];
	$heigh         = $rows['heigh'];
	$edu           = $rows['edu'];
	$click         = $rows['click'];
	$agree         = intval($rows['agree']);
	$dst_s         = UP.$path_s;
	$flag         = $rows['flag'];
	$photo_ifshow = $rows['photo_ifshow'];
	$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$flag.'","outkind":"url"}');	
	if($flag==-2)$nickname='***';
	$ifh4 = ($birthday == '0000-00-00' && empty($pay) && empty($edu))?false:true;
	if ($ifh4){
		$birthday_str = (getage($birthday)<=0)?'':getage($birthday).'岁•';
		$edu_str      = (empty($edu))?'':udata('edu',$edu).'•';
		$pay_str      = (empty($pay))?'':udata('pay',$pay);
	}
	$echo  = '<li>';
	$echo .= '<p><a href="'.mHref('video',$id).'"><img src="'.$dst_s.'"><i class="play ico">&#xe603;</i></a></p>';
	$echo .= '';
	$echo .= '<dt class="uA" onClick="uA('.$uid.')">';
		$echo .= '<img src="'.$photo_s_url.'">';
		$echo .= '<em>';//<h3>'.$nickname.'</h3>
		if ($ifh4){
			$echo .= '<h4>'.$birthday_str.$edu_str.$pay_str.'</h4>';
		}
		$echo .= '</em>';
	$echo .= '</dt>';
	$echo .= '<span class="agree" vid="'.$id.'"><i class="ico">&#xe652;</i> <font>'.$agree.'</font></span>';
	$echo .= '<span class="click"><i class="ico">&#xe643;</i> <font>'.$click.'</font></span>';
	$echo .= '</li>';
	return $echo;
}
?>